package com.yida.gwj.expend.outside.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yida.common.core.web.controller.BaseController;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.log.annotation.Log;
import com.yida.common.log.enums.BusinessType;
import com.yida.gwj.expend.outside.domain.GwjMaintenanceFundsBusinessAttachment;
import com.yida.gwj.expend.outside.domain.request.InsertAttachmentInfoRequest;
import com.yida.gwj.expend.outside.service.IGwjMaintenanceFundsBusinessAttachmentService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 附件信息业务
 *
 * @author lgp
 * @date 2023-03-21
 * 
 * 
 * @author hmh
 * @date 2023-06-07
 * 
 *       前端未使用，进行权限移除
 * 
 * @date 2023-06-09
 * 
 *       新增操作日志记录
 */
@Api(value = "附件材料信息业务", tags = "附件材料信息业务")
@RestController
@RequestMapping("/expend/outside/attachment")
public class GwjMaintenanceFundsBusinessAttachmentController extends BaseController {
    @Autowired
    private IGwjMaintenanceFundsBusinessAttachmentService gwjMaintenanceFundsBusinessAttachmentService;

    @ApiOperation(value = "查询附件材料信息业务列表", response = GwjMaintenanceFundsBusinessAttachment.class)
    // @RequiresPermissions("gwj:attachment:list")
    @GetMapping("/list")
    public AjaxResult list(GwjMaintenanceFundsBusinessAttachment gwjMaintenanceFundsBusinessAttachment) {
        return AjaxResult.success(gwjMaintenanceFundsBusinessAttachmentService.selectGwjMaintenanceFundsBusinessAttachmentList(gwjMaintenanceFundsBusinessAttachment));
    }

    @ApiOperation(value = "获取附件材料信息业务详细信息", response = GwjMaintenanceFundsBusinessAttachment.class)
    // @RequiresPermissions("gwj:attachment:query")
    @GetMapping(value = "/{attachmentId}")
    public AjaxResult getInfo(@PathVariable("attachmentId") Long attachmentId) {
        return AjaxResult.success(gwjMaintenanceFundsBusinessAttachmentService.selectGwjMaintenanceFundsBusinessAttachmentByAttachmentId(attachmentId));
    }

    @Log(title = "附件材料信息", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改附件材料信息业务信息")
    // @RequiresPermissions("gwj:attachment:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody GwjMaintenanceFundsBusinessAttachment gwjMaintenanceFundsBusinessAttachment) {
        return toAjax(gwjMaintenanceFundsBusinessAttachmentService.updateGwjMaintenanceFundsBusinessAttachment(gwjMaintenanceFundsBusinessAttachment));
    }

    @Log(title = "附件材料信息", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除附件材料信息业务信息")
    // @RequiresPermissions("gwj:attachment:remove")
    @DeleteMapping("/{attachmentId}")
    public AjaxResult remove(@PathVariable Long attachmentId) {
        return toAjax(gwjMaintenanceFundsBusinessAttachmentService.deleteGwjMaintenanceFundsBusinessAttachmentByAttachmentId(attachmentId));
    }

    @Log(title = "附件材料信息", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增上传材料图片地址")
    // @RequiresPermissions("gwj:attachment:add")
    @PostMapping
    public AjaxResult insertAttachmentInfo(@RequestBody InsertAttachmentInfoRequest insertAttachmentInfoRequest) {
        return AjaxResult.success(gwjMaintenanceFundsBusinessAttachmentService.insertAttachmentInfo(insertAttachmentInfoRequest));
    }

    @ApiOperation(value = "通过业务标识获取附件材料信息", response = GwjMaintenanceFundsBusinessAttachment.class)
    // @RequiresPermissions("gwj:attachment:query")
    @GetMapping(value = "/getInfo")
    public AjaxResult getInfoByServerIdentification(GwjMaintenanceFundsBusinessAttachment maintenanceFundsBusinessAttachment) {
        return AjaxResult.success(gwjMaintenanceFundsBusinessAttachmentService.getGwjMaintenanceFundsBusinessAttachment(maintenanceFundsBusinessAttachment));
    }

    @Log(title = "附件材料信息", businessType = BusinessType.INSERT)
    @ApiOperation(value = "多附件材料上传")
    // @RequiresPermissions("gwj:attachment:add")
    @PostMapping("/batchInsert")
    public AjaxResult batchInsertAttachmentInfo(@RequestBody List<InsertAttachmentInfoRequest> insertAttachmentInfoRequestList) {
        return AjaxResult.success(gwjMaintenanceFundsBusinessAttachmentService.batchInsertAttachmentInfo(insertAttachmentInfoRequestList));
    }

}
